fix: persist bearer scan_history on /api/check/stream cache hit#538
Open
cursor[bot] wants to merge 1 commit into
Open
fix: persist bearer scan_history on /api/check/stream cache hit#538cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
GET /api/check already calls persistBearerScanIfWatched on cache hits so Pro API scans of watched domains update scan_history. The streaming sibling returned early on cache hit without persisting, leaving last_grade and scan_history stale for up to five minutes while the client saw a successful scan. Mirror the JSON endpoint: invoke persistBearerScanIfWatched after replaying cached SSE events. Regression test drains the stream and asserts recordScan runs for watched domains only. Co-authored-by: schmug <schmug@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
dmarcheck | 2e2cf7b | Jun 13 2026, 11:09 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Bearer-authenticated
GET /api/check/streamskippedpersistBearerScanIfWatchedon cache hits. When a Pro user's watched domain was scanned within the 5-minute edge cache TTL, the stream endpoint replayed cached SSE events successfully but never wrote toscan_historyor updateddomains.last_grade/last_scanned_at.Concrete trigger: User watches
example.com→ any scan populates cache → within 5 minutes, same user calls/api/check/stream?domain=example.comwith bearer auth → dashboard/history stay stale despite a "successful" streamed scan.The JSON sibling
GET /api/checkalready persisted on cache hits; only the stream path regressed.Root cause
The cache-hit branch in
/api/check/streamreturned immediately after replaying SSE events.persistBearerScanIfWatchedwas only invoked on the cache-miss path afterscanStreaming()completed.Fix
Call
persistBearerScanIfWatchedin the cache-hit branch, mirroring/api/check.Validation
test/api-check-stream-bearer-persist.test.tsnpm run lintclean